package demo4;

import java.util.Objects;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: liangyuanzhang
 * Date: 2025-2-28
 * Time: 8:26
 */
public class Dog extends Animal implements ISwimming,IRunning{

    public Dog(String name,int age) {
        super(name,age);
    }

    public void eat() {
        System.out.println(this.name+" 正在吃狗粮...");
    }

    public void bark() {
        System.out.println(this.name + " 正在汪汪汪叫.....");
    }

    @Override
    public void run() {
        System.out.println(this.name +" 正在跑.....");
    }

    @Override
    public void swim() {
        System.out.println(this.name +" 正在游泳.....");
    }

    public  int hashCode() {
        return Objects.hash(name,age);
    }

    @Override
    public boolean equals(Object obj) {
        if(obj == null) {
            return false;
        }
        if(this == obj) {
            return true;
        }
        //是不同同一个类型
        if(!(obj instanceof Dog)) {
            return false;
        }

        Dog tmp = (Dog)obj;
        return tmp.name.equals(this.name)
                && tmp.age == this.age;
    }


}
